import request from "@/utils/request";

/**
 * 合同模板列表
 * @param { ContractTemplateParams } params
 * @returns { ContractTemplateData }
 */
export const contractTemplateList = params =>
  request({
    url: "/contract/template/pageList",
    method: "get",
    params
  });

/**
 * 创建合同模板
 * @param { CreateContractTemplateParams } data
 */
export const createContractTemplate = data =>
  request({
    url: "/contract/template/create",
    method: "post",
    data
  });

/**
 * 更新模板
 * @param { CreateContractTemplateParams } data
 * @param templateId
 */
export const updateContractTemplate = (data, templateId) =>
  request({
    url: `/contract/template/update/${templateId}`,
    method: "put",
    data
  });

/**
 * 合同模板配置信息
 * @returns { ContractTemplateConfigItem[] }
 */
export const contractTemplateConfig = () =>
  request({
    url: "/contract/template/config",
    method: "get"
  });

/**
 * 设置模板状态
 * @param { number } id
 * @param { number } status
 */
export const setTemplateStatus = (id, status) =>
  request({
    url: `/contract/template/setStatus/${id}/${status}`,
    method: "put"
  });

/**
 * 模板详情
 * @returns { ContractTemplateDetail }
 */
export const contractTemplateDetail = templateId =>
  request({
    url: `/contract/template/detail/${templateId}`,
    method: "get"
  });
/**
 * 下载模板
 * @param { CreateContractTemplateParams } data
 */
export const downContractTemplate = data =>
    request({
        url: "/contract/template/downloadWord",
        method: "post",
        data,
        responseType: "blob"
    });
/**
 * 工程预算清单清单配置
 * @returns { ContractTemplateDetail }
 */
export const templateSet = templateId =>
    request({
        url: "/contract/template",
        method: "get"
    });